package com.zhongkun.datahome.service.export.handler;

import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import com.alibaba.excel.write.metadata.style.WriteFont;
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
import org.apache.poi.ss.usermodel.*;

/**
 * @Author: lifengsheng
 * @Date: 2025/5/12 18:16
 * @Desc
 */
public class CustomCellStyleStrategy {

    public HorizontalCellStyleStrategy getCustomerHouseExcelStrategy() {
        // 创建表头样式
        WriteCellStyle headStyle = new WriteCellStyle();
        WriteFont headFont = new WriteFont();
        headFont.setFontHeightInPoints((short) 12); // 表头字体14磅（注意：实际是12磅，14磅需调整）
        headStyle.setWriteFont(headFont);
        headStyle.setVerticalAlignment(VerticalAlignment.CENTER); // 垂直居中
        headStyle.setHorizontalAlignment(HorizontalAlignment.CENTER); // 水平居中

        // 创建内容样式（重点修改：添加边框）
        WriteCellStyle contentStyle = new WriteCellStyle();
        WriteFont contentFont = new WriteFont();
        contentFont.setFontHeightInPoints((short) 11); // 内容字体12磅（实际11磅）
        contentStyle.setWriteFont(contentFont);
        contentStyle.setVerticalAlignment(VerticalAlignment.CENTER); // 垂直居中
        contentStyle.setHorizontalAlignment(HorizontalAlignment.CENTER); // 水平居中

        // ---------------- 关键：添加内容单元格边框 ----------------
        // 设置四边边框（细线，黑色）
        contentStyle.setBorderLeft(BorderStyle.THIN);   // 左边框
        contentStyle.setBorderRight(BorderStyle.THIN);  // 右边框
        contentStyle.setBorderTop(BorderStyle.THIN);    // 上边框
        contentStyle.setBorderBottom(BorderStyle.THIN); // 下边框

        return new HorizontalCellStyleStrategy(headStyle, contentStyle);
    }
}
